﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using RooHui.Infrastructure.Entities.EFContext;
using RooHui.Infrastructure.Entities.Repository;

namespace RooHui.Infrastructure.Entities.Entity
{
    public class ProcessDoingHistory : IAccessible<P_ProcessDoingHistory, ProcessDoingHistory>, ILogicEntity<P_ProcessDoingHistory, ProcessDoingHistory>
    {
        public int ID { get; set; }
        public int Type { get; set; }
        public int ProjectID { get; set; }
        public int ProcessID { get; set; }
        public int ProcessStepID { get; set; }
        public int ChangeState { get; set; }
        public int DoDirection { get; set; }
        public DateTime DoingTime { get; set; }
        public string DoingUser { get; set; }
        public string DoingContent { get; set; }

        public User User { get; set; }
        public ProcessDoing ProcessDoing { get; set; }

        public ProcessDoingHistory LoadUser(U_User u_user)
        {
            this.User = new User().Set(u_user);
            return this;
        }

        public ProcessDoingHistory LoadProcessDoing(P_ProcessDoing p_processDoing)
        {
            this.ProcessDoing = new ProcessDoing().Set(p_processDoing);
            return this;
        }

        protected override void Covariant(P_ProcessDoingHistory model)
        {
            if (model != null)
            {
                this.ChangeState = model.ChangeState;
                this.DoDirection = model.DoDirection;
                this.DoingContent = model.DoingContent;
                this.DoingTime = model.DoingTime;
                this.DoingUser = model.DoingUser;
                this.ID = model.ID;
                this.ProcessID = model.ProcessID;
                this.ProcessStepID = model.ProcessStepID;
                this.ProjectID = model.ProjectID;
                this.Type = model.Type;
            }
        }

        protected override P_ProcessDoingHistory Inverter(ProcessDoingHistory model)
        {
            if (model != null)
            {
                return new P_ProcessDoingHistory()
                {
                    ChangeState = model.ChangeState,
                    DoDirection = model.DoDirection,
                    DoingContent = model.DoingContent,
                    DoingTime = model.DoingTime,
                    DoingUser = model.DoingUser,
                    ID = model.ID,
                    ProcessID = model.ProcessID,
                    ProcessStepID = model.ProcessStepID,
                    ProjectID = model.ProjectID,
                    Type = model.Type
                };
            }
            return null;
        }

        public ProcessDoingHistory Set(P_ProcessDoingHistory dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
